package com.zcmob.web.admanagement.vo;

import java.io.File;

public class StringTest {
private static String rootPath;

/*
    *//**
     * @param args
     *//*
    public static void main(String[] args) {

        String len = "<activity android:theme=\"@style/Theme.NoShadow\" android:label=\"@string/app_name\" android:name=\"com.sina.AppEntry\" android:launchMode=\"singleTask\" android:screenOrientation=\"user\" android:configChanges=\"keyboardHidden|orientation|screenSize\" android:windowSoftInputMode=\"stateHidden|adjustResize\">";
        
        if (len.contains("<activity")) {
            String tmp = len.substring(len.indexOf("android:name") + 14, len.length());
            String activityName = tmp.substring(0, tmp.indexOf("\""));
            
            String [] arrays = activityName.split("\\.");
            
            String result = null;
            if (arrays.length == 1) {
                result = "packagename." + arrays[0];
            } else if (arrays.length == 2 && arrays[0].equals("")) {
                result = "packagename." + arrays[1];
            } else {
                result = activityName;
            }
            
            System.out.println(result);
        }
    }
*/
    
    private static void renameImages(String packagename) {

        String resPath = rootPath + packagename + "\\res";
        
        for (File path : new File(resPath).listFiles()) {
            if (path.getName().startsWith("drawable")) {
                for (File image : path.listFiles()) {
                    if (image.getName().endsWith(".9.png") || image.getName().endsWith(".9.jpg")) {
                        String des = path + image.getName().substring(0, image.getName().length() - 6) + "\\" + image.getName().substring(image.getName().length() - 4, image.getName().length());
                        System.out.println("rename: " + des);
                        image.renameTo(new File(des));
                    }
                }
            }
        }
        
    }
    
    public static void main(String[] args) {
        rootPath = "D:\\batchapks\\apks\\";
        renameImages("com.kiloo.subwaysurf");
    }
}
